package com.lagou.job.controller;

import com.lagou.job.common.Result;
import com.lagou.job.pojo.Position;
import com.lagou.job.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 职位控制类
 * @author yzh
 */
@RestController
@RequestMapping("position")
public class PositionController {

    @Autowired
    private PositionService positionService;

    /**
     * 获取热点职位
     * @return
     */
    @GetMapping("getHotPosition")
    public Result getHotPosition() {
        List<Position> allPosition = null;
        try {
            allPosition = positionService.getHotPositionFromLocalCache();
            return Result.success(allPosition);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(allPosition);
        }
    }
}
